<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">职工列表</view>
		</stop>
		<view class="bcf padlr3 padtb2 bdtso flrc">
			<view class="flex1"><search class="fs8 tac" placeholder=" 姓名 \ 手机号称 "  v-model="search" @search="doSearch()"></search></view>
			<view class="marl10">
				<view class="cu-btn bg-green round pos-r" @tap="goto('/pages/user/user_info_edit')"> 新增 <ripple></ripple></view>
			</view>
		</view>
		<view class="padlr3">
			<view class="bcf pos-r mart3 pad2 round2 shadow" 
			v-for="user in data" :key="user.id">
				<view class="pos-r" @tap="goto('/pages/user/user_info_edit?id=' + user.id)">
				<!-- <view class="pos-r"> -->
					<user-item :item="user"></user-item>
					<ripple></ripple>
				</view>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../assets/js/list.js'
	
	import userItem from '../../templete/machine/user_item.vue'
	
	export default {
		mixins:[MescrollMixin],
		components:{userItem},
		data() {
			let list = new List()
			return {
				list,
				where:{
					eq:{
						status:'',
						emergency:'',
						level:'',
					}
				},
				search:"",
				data:[]
			}
		},
		methods: {
			reload(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			confirm(id){
				// this.$api.post('/api/storeIns/confirm/'+id,{},res=>{
				// 	this.reload()
				// })
				this.goto('/pages/store/store_out_check_form?id=' + id)
			},
			deleteIt(id){
				this.$api.delete('/api/machineUsers/'+id,{},res=>{
					this.log(res)
					this.reload()
				})
			}
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/machineUsers').setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.log("onshow")
			this.showLoading()
			this.list.reload()
		},
		watch:{
		}
	}
</script>

<style>

</style>
